import { Context, Application } from 'egg'
import { BizConfig } from '../../config/config.default'

export default (options: BizConfig['sampleOptions'], app: Application) => {
  return async (ctx: Context, next: () => Promise<any>) => {
    app.logger.info('sample middleware body', ctx.request.body)
    await next()
    ctx.endtime = new Date().valueOf()
    app.logger.info(`sample middleware at ${new Date(ctx.starttime)} end ${new Date(ctx.endtime)}`)
  }
}
